package itstudio.instructor.ui;

import java.util.ArrayList;
import java.util.List;
import itstudio.instructor.adapter.UserListAdapter;
import itstudio.instructor.entity.User;
import itstudio.instructor.xlistview.XListView;
import com.easemob.chatuidemo.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class UserTeacherFragment extends Fragment {
	
    private View rootView ;
    private XListView xListView;
    private UserListAdapter adapter;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
        if (rootView == null) {
            rootView = inflater.inflate(R.layout.xlistview, container,false);
            bindViews();
        }
        ViewGroup parent = (ViewGroup) rootView.getParent();
        if (parent != null) {
            parent.removeView(rootView);
        }
        return rootView;
	}
	private void bindViews() {
		xListView = (XListView) rootView.findViewById(R.id.xlistView);
		adapter = new UserListAdapter(getActivity(), null);
		xListView.setAdapter(adapter);
		xListView.setPullRefreshEnable(false);
		xListView.setPullLoadEnable(false);
		adapter.appendToList(testData());
	}
	private List<User> testData() {
		List<User> userList = new ArrayList<User>();
		User u1= new User();
		u1.setName("张国豪");
		u1.setIntro("人所缺乏的不是才干而是志向，不是成功的能力而是成功的意志");
		u1.setHeadUrl("drawable://"+R.drawable.t_user_zhang);
		u1.setFocus(false);
		userList.add(u1);
		User u2= new User();
		u2.setName("孙倩");
		u2.setIntro("志向不过是记忆的奴隶,生气勃勃地降生,但却很难成长");
		u2.setHeadUrl("drawable://"+R.drawable.t_user_sun);
		u2.setFocus(true);
		userList.add(u2);
		User u3= new User();
		u3.setName("林黛玉");
		u3.setIntro("真正的才智是刚毅的意志");
		u3.setHeadUrl("drawable://"+R.drawable.t_user_lin);
		u3.setFocus(true);
		userList.add(u3);
		return userList;
	}
}
